<template>
	<div class="toplist">
		<div class="title">
			<img src="../../assets/newPage/miaosha.png" alt="" class="miaosha">
			
		</div>
		<div class="title">
			<span>&nbsp;</span>
			<img src="../../assets/newPage/m_logo.png" alt="" class="m_logo">
			<span class="lookmore" @click="topList">查看更多</span>
		</div>
		<div class="times">
			<div class="hours">
				<span class="first">8</span>
				<span class="second">8</span>
			</div>
			<img src="../../assets/newPage/time.png" >
			<div class="hours">
				<span class="first">8</span>
				<span class="second">8</span>
			</div>
			<img src="../../assets/newPage/time.png" >
			<div class="hours">
				<span class="first">8</span>
				<span class="second">8</span>
			</div>
		</div>
		<!-- <div class="tags">
			<span v-for="items in 5" :key="items" :class="active==items?'active':''">冷藏冷冻</span>
		</div> -->
		<div class="top-other">
			<el-carousel :interval="5000" arrow="always" height="29.5rem" indicator-position="none">
				<el-carousel-item v-for="items in count" :key="items">
					<div v-for="(item, str) in list" v-if="(str-1) >= (items - 1) * 5 && (str-1) < items * 5&&str>0"
						:key="str" class="goods-item" @click="goDetail(item)">
						<div>
							<img :src="item.defaultAlbum" alt="" class="goods-img">
							<div class="goods-info">
								<p class="name">
									{{ item.pName }}
								</p>
								<p class="desc">
									{{ item.cSellingPoint }}
								</p>
								<p class="price">
									
									<span class="new">￥ {{ item.fSalePrice }}</span>
									<span class="old">￥ {{ item.pfMarkPrice }}</span>
								</p>
								
								
							</div>
						</div>
					</div>
				</el-carousel-item>
			</el-carousel>
		</div>
		
		
	</div>
</template>

<script>
	export default {
		name: "",
		components: {},
		props: {
			data: {
				type: Object,
				// 对象或数组默认值必须从一个工厂函数获取
				default: function() {
					return {};
				},
			},
		},
		data() {
			return {
				list: [],
				count: "",
				coverList: [],
				second: {},
				active:1
			};
		},
		mounted() {
			
			let params = {
				queryCondition: {
					order: [{
						fieldname: "iOrder",
						direction: "asc",
					}, ],
					pageindex: 1,
					pagesize: 16,
					where: [{
						fieldname: "tag_id",
						valuefrom: this.data.connect_id,
					}, ],
				},
			};
			
			this.$api.home.getProductList(params).then((res) => {
				if (res.code == 200) {
					this.list = res.data.data;
					if (res.data.data.length >= 1) {
						this.count = Math.ceil((res.data.data.length - 1) / 5);
					} else {
						this.count = 1
					}
				}
			});
		},
		methods: {
			topList() {
				this.$router.push({
					path: "/today",
					query: {
						id: this.data.connect_id,
					},
				});
			},
			//跳转商品详情
			goDetail(item) {
				console.log('跳转商品详情', item)
				if (item === undefined) {
					return
				} else {
					this.$router.push({
						path: "/fruit/detail",
						query: {
							id: item.pid,
							iShopId: item.iShopId
						}
					})
				}
			},
		},
	};
</script>

<style scoped lang="scss">
	.toplist {
		
		margin-top: 2.19rem;
		display: flex;
		flex-direction: column;
		padding: 0;
		.title {
			padding: 0 10rem;
			
			display: flex;
			// flex-direction: column;
			justify-content: center;
			align-items: center;
			position: relative;
			.miaosha{
				width: 16.13rem;
				object-fit: contain;
				margin-bottom: 1.13rem;
			}
			.m_logo{
				width: 18.25rem;
				object-fit: contain;
				margin-bottom: 3.69rem;
			}
			.lookmore{
				font-size: 1.13rem;
				font-family: SourceHanSansCN;
				font-weight: 400;
				color: #999999;
				cursor: pointer;
				float: right;
				position: absolute;
				right: 10rem;
				bottom: -3rem;
			}
			
		}
		
		.times{
			display: flex;
			justify-content: center;
			align-items: center;
			.hours{
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 6rem;
				height: 4rem;
				span{
					display: flex;
					justify-content: center;
					align-items: center;
					width: 2.7rem;
					height: 3.99rem;
					background: #E8FCF8;
					border: 1px solid #1BE0BA;
					border-radius: 0.1rem;
					font-size: 3.01rem;
					font-family: Microsoft YaHei;
					font-weight: bold;
					color: #08D7AF;
				}
				
			}
			img{
				width: 0.63rem;
				object-fit: contain;
				margin: 0 0.75rem;
			}
		}

		.top-other {
			// margin-top: 1.25rem;
			margin-bottom: 1.25rem;
			padding: 0 10rem;
			.el-carousel__item {
				display: flex;
				align-items: center;
				justify-content: flex-start;

				.goods-item {
					width: 19rem;
					min-height: 25.75rem;
					background: #fff;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: space-around;
					position: relative;
					margin-right: 1.25rem;
					cursor: pointer;
					text-align: center;
					box-shadow: 0rem 1rem 2rem 0rem rgba(145, 145, 145, 0.19);
					&:nth-child(5n) {
						margin-right: 0;
					}

					.goods-img {
						width: 15rem;
						height: 15rem;
						object-fit: contain;
					}

					.goods-info {
						display: flex;
						flex-direction: column;
						text-align: center;
						padding: 0 1rem;
						margin-top: 2rem;

						.name {
							font-size: 1.25rem;
							font-family: SourceHanSansCN;
							font-weight: 400;
							color: #000000;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
							width: 18rem;
							line-height: 1.5;
						}
						.desc{
							font-size: 1rem;
							font-family: SourceHanSansCN;
							font-weight: 400;
							color: #333333;
							opacity: 0.5;
							margin-top: 1.13rem;
							margin-bottom: 1.6rem;
							text-align: center;
						}
						
							.price{
								display: flex;
								justify-content: center;
								align-items: center;
								margin-bottom: 2rem;
								.new{
									font-size: 1.25rem;
									font-family: SourceHanSansCN;
									font-weight: 400;
									color: #FF0000;
									margin-right: 0.94rem;
								}
								.old{
									font-size: 1.25rem;
									font-family: SourceHanSansCN;
									font-weight: 400;
									text-decoration: line-through;
									color: #000000;
									opacity: 0.4;
								}
								
							}
						
					}
				}
			}
		}

		.more {
			height: 2.5rem;
			background: rgba(0, 0, 0, 1);
			display: flex;
			justify-content: flex-end;
			align-items: center;
			padding: 0 1.44rem;

			img {
				width: 7.38rem;
				cursor: pointer;
			}
		}
	}
</style>
<style>
	.el-carousel__arrow:hover{
		background-color: #000!important;
	}
</style>